package com.sdy.dcsb.web.controller;

import com.sdy.common.model.Response;
import com.sdy.dcsb.biz.model.EsbLogReqJoint;
import com.sdy.dcsb.biz.service.EsbLogReqService;
import com.sdy.mvc.controller.BaseController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import java.util.List;
import static org.springframework.util.StringUtils.isEmpty;

/**
 * <p>
 * 服务报文日志表(请求和返回) 前端控制器
 * </p>
 *
 * @author fb
 * @since 2019-10-11
 */
@Slf4j
@Controller
@RequestMapping("/EsbLogReq")
@Api(tags = "服务日志报文相关接口")
public class EsbLogReqController extends BaseController {
    @Autowired
    private EsbLogReqService esbLogReqService;

    /**
     * 查询当前流水id的服务调用日志报文详情数据
     * @param id ,当前流水id
     * @return
     */
    @GetMapping("/selectDetailedMsg")
    @ResponseBody
    @ApiOperation("查询当前流水id的服务调用日志报文详情数据")
    @ApiImplicitParams({
            @ApiImplicitParam(dataType = "Integer", name = "id", value = "当前流水id"),
    })
    public Response selectDetailedMsg(Integer id) {
        if(!isEmpty(id)) {
            List<EsbLogReqJoint> result = esbLogReqService.findOneServiceLogMsg(id);
            return Response.success(result);
        }else {
            return Response.error("流水id不能为空");
        }
    }

}
